/**
 * @(#)GenericMethodDemo.java, 2020/8/21.
 * <p/>
 * Copyright 2020 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.lhh.myspringboot.Boke;

/**
 * @author lvhouhou(lvhouhou @ 163.com)
 */
public class GenericMethodDemo {
    public static void main(String[] args){
        Integer [] integers = {1, 2, 3, 4, 5};
        String [] strings = {"London", "Paris", "New York", "Austin"};
        GenericMethodDemo.<Integer> print(integers);
        GenericMethodDemo.<String> print(strings);

        //简单调用——这里实际类型没有明确，编译器自动发现实际类型
        print(integers);
        print(strings);

    }

    /*泛型方法  遍历打印list*/
    public static <E> void print(E[] list){
        for (int i = 0; i < list.length; i++) {
            System.out.println(list[i] + " ");
        }
    }
}
